﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DiracTCC.Business
{
    public enum SubBlockSplitMode
    {
        None = 0,
        Sub2x2 = 1,
        Sub4x4 = 2
    }
    public enum SubBlockPredictionMode
    {
        Intra = 0,
        Ref1Only = 1,
        Ref2Only = 2,
        Ref1AndRef2 = 3
    }

    public class SubBlockInfo
    {
        public double Cost { get; set; }
        public SubBlockSplitMode SplitMode { get; set; }
        public SubBlockPredictionMode[] PredictionModes { get; set; }
    }

    public class SubBlockArray
    {
        public Dictionary<string, SubBlockInfo> subBlocks;

        public SubBlockArray()
        {
            subBlocks = new Dictionary<string, SubBlockInfo>();
        }

        public void AddSubBlockInfo(int x, int y, double cost, SubBlockSplitMode mode, SubBlockPredictionMode[] predictionModes)
        {
            subBlocks.Add(x.ToString() + "," + y.ToString(), new SubBlockInfo { Cost = cost, SplitMode = mode, PredictionModes = predictionModes });
        }

        public SubBlockInfo GetSubBlock(int x, int y)
        {
            if (subBlocks.Keys.Contains(x.ToString() + "," + y.ToString()))
            {
                return subBlocks[x.ToString() + "," + y.ToString()];
            }
            else
            {
                return new SubBlockInfo();
            }
            
        }
    }
}
